package com.wfh.rpc.protocal;

import lombok.Getter;

/**
 * @Title: ProtocalMessageTypeEnum
 * @Author wangfenghuan
 * @Package com.wfh.rpc.protocal
 * @Date 2025/10/14 21:06
 * @description: 协议消息类型枚举
 */
@Getter
public enum ProtocolMessageTypeEnum {

    /**
     * 协议消息类型枚举
     */
    REQUEST(0),
    RESPONSE(1),
    HEART_BEAT(2),
    OTHERS(3);

    private final int key;

    ProtocolMessageTypeEnum(int key){
        this.key = key;
    }

    public static ProtocolMessageTypeEnum getByKey(int key){
        for (ProtocolMessageTypeEnum value : ProtocolMessageTypeEnum.values()) {
            if (value.key == key) return value;
        }
        return null;
    }
}
